
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;


import TaggingSys.FileLabeler;

public class TagsLoader {
	
	
	public TagsLoader() {
	
	}

	@SuppressWarnings({ "deprecation", "unchecked" })
	//*****************************NEED TO ADD FILE NAME AS A PARAMETER
	public String[] LoadTag(String path,String policy) throws ClassNotFoundException, MalformedURLException, InstantiationException, IllegalAccessException{
		//***************************NEED TO ADD THE USER PATH!!!!!!!!!!
			File file = new File("C:/Users/HP/workspace/CleverDropBox/build/classes");
			URL url = file.toURL();
			URL[] urls = new URL[]{url};
			ClassLoader cl = new URLClassLoader(urls);
			Class<FileLabeler> cls = (Class<FileLabeler>) cl.loadClass(policy);
			FileLabeler fl = (FileLabeler)cls.newInstance();
			//***************************NEED TO ADD THE FILE PATH!!!!!!!!!!
			File f = new File(path);
			System.out.println(f.exists());
			if (f.exists()==false){
				return null;
			}
			String[] labels = fl.label(f);
//		/	System.out.println(labels[0]);
			return labels;
	}
}
